﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CarHelpDesk.Web.Models.Repositories
{
    public interface IQuestionsRepository
    {
        /// <summary>
        /// Gets all the questions.
        /// </summary>
        /// <returns></returns>
        IQueryable<Question> GetQuestions();


        /// <summary>
        /// Gets questions with text in title.
        /// </summary>
        /// <returns></returns>
        IQueryable<Question> SearchByText(string text);

        /// <summary>
        /// Gets questions in text in the answers
        /// </summary>
        /// <returns></returns>
        IQueryable<Question> SearchInAswers(string text);

        /// <summary>
        /// Gets questions with the given categories (&&)
        /// </summary>
        /// <param name="categories">categories to look in</param>
        /// <returns></returns>
        IQueryable<Question> SearchByTag(List<Tag> tags);


        /// <summary>
        /// Saves question to the database
        /// </summary>
        /// <param name="question">The question.</param>
        void Create(Question question);


        /// <summary>
        /// Gets question by ID
        /// </summary>
        /// <param name="questionID">The question ID.</param>
        /// <returns></returns>
        Question GetByID(int questionID);

        /// <summary>
        /// Marks the question as favourite for given user and returns its current state.
        /// </summary>
        /// <param name="favQuestion">The fav question.</param>
        /// <returns><c>true</c> if question is currently favourited; otherwise, <c>false</c></returns>
        bool QuestionToogleFavourite(FavouriteQuestion favQuestion);

        /// <summary>
        /// Determines whether question is favourited by the specified user.
        /// </summary>
        /// <param name="question">The question to be checked</param>
        /// <param name="guid">The GUID of the user.</param>
        /// <returns>
        /// 	<c>true</c> if [is favourited by] [the specified GUID]; otherwise, <c>false</c>.
        /// </returns>
        bool IsFavouritedBy(int questionID, Guid guid);

        /// <summary>
        /// Gets the questions favourited by the specified user.
        /// </summary>
        /// <param name="userID">The user's GUID.</param>
        /// <returns></returns>
        IQueryable<Question> GetQuestionsFavouritedBy(Guid userID);

        /// <summary>
        /// Toogles marks question as flagged for moderator attention and return its current state
        /// </summary>
        /// <param name="flaggedQuestion">The flagged question.</param>
        /// <returns><c>true</c> if is currently flagged; otherwise, <c>false</c></returns>
        bool QuestionToggleFlagged(QuestionAttentionFlag flaggedQuestion);

        /// <summary>
        /// Gets the questions marked as flagged for moderation attention.
        /// </summary>
        /// <returns>Collection with flagged for moderator attention questions.</returns>
        IQueryable<Question> GetQuestionsMarkedAsFlagged();

        /// <summary>
        /// Creates the question vote.
        /// </summary>
        /// <param name="vote">The vote.</param>
        void CreateQuestionVote(QuestionVote vote);

        /// <summary>
        /// Gets QuestionVote created by user.
        /// </summary>
        /// <param name="question">The question.</param>
        /// <param name="userID">The user ID.</param>
        /// <returns>QuestionVote ot null if there is none</returns>
        QuestionVote GetQuestionVote(Question question, Guid userID);


        /// <summary>
        /// Change question's content by ID.
        /// </summary>
        /// <param name="id">Question ID.</param>
        /// <param name="content">New question's content.</param>
        void UpdateQuestionContentById(int id, string content);

        /// <summary>
        /// Delete a question by an ID. (Make it not active)
        /// </summary>
        /// <param name="id">Question ID</param>
        void DeleteQuestionById(int id);

        /// <summary>
        /// Delete permanently a question by an ID.
        /// </summary>
        /// <param name="id">Question ID</param>
        void ModeratorDeleteQuestionById(int id);

        /// <summary>
        /// Make a question active.
        /// </summary>
        /// <param name="id">Question ID</param>
        void RevertQuestionById(int id);
    }
}
